﻿using B.S.Orders.Domain;
using B.S.Orders.ErrorCord;
using B.S.Orders.Read.Api.Application.Commands.ProjectModelCommand;
using B.S.Orders.Read.Api.DTO;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Orders.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProjectController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProjectController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 项目名称
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIPaging<List<ProjectDtos>>> QueryProject([FromQuery] QueryProjectModelCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 反填项目名称
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ProjectModel>>> ShowProject([FromQuery] ShowProjectModelCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
